package com.qvtu.poetry.entry;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import lombok.Data;

/**
 * 诗歌表
 * @TableName t_poem
 */
@TableName(value ="t_poem")
@Data
public class Poem {
    /**
     * 诗歌唯一标识
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 诗歌作者ID
     */
    private Long userId;

    /**
     * 诗歌标题
     */
    private String title;

    /**
     * 诗歌内容
     */
    private String content;

    /**
     * 诗歌风格
     */
    private String styleType;

    /**
     * 主题关键词
     */
    private String themeKeyword;

    /**
     * 生成/创作时间
     */
    private LocalDateTime createTime;

    /**
     * 最后修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 诗歌状态（0-草稿，1-已发布，2-已删除）
     */
    private Integer status;

    /**
     * 分享次数
     */
    private Integer shareCount;

    /**
     * 查看次数
     */
    private Integer viewCount;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Poem other = (Poem) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
            && (this.getStyleType() == null ? other.getStyleType() == null : this.getStyleType().equals(other.getStyleType()))
            && (this.getThemeKeyword() == null ? other.getThemeKeyword() == null : this.getThemeKeyword().equals(other.getThemeKeyword()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getShareCount() == null ? other.getShareCount() == null : this.getShareCount().equals(other.getShareCount()))
            && (this.getViewCount() == null ? other.getViewCount() == null : this.getViewCount().equals(other.getViewCount()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
        result = prime * result + ((getStyleType() == null) ? 0 : getStyleType().hashCode());
        result = prime * result + ((getThemeKeyword() == null) ? 0 : getThemeKeyword().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getShareCount() == null) ? 0 : getShareCount().hashCode());
        result = prime * result + ((getViewCount() == null) ? 0 : getViewCount().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", userId=").append(userId);
        sb.append(", title=").append(title);
        sb.append(", content=").append(content);
        sb.append(", styleType=").append(styleType);
        sb.append(", themeKeyword=").append(themeKeyword);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", status=").append(status);
        sb.append(", shareCount=").append(shareCount);
        sb.append(", viewCount=").append(viewCount);
        sb.append("]");
        return sb.toString();
    }
}